package com.meiyou.controller;

import com.meiyou.dto.HandleReportDto;
import com.meiyou.dto.ReportArticleDto;
import com.meiyou.dto.ReportPageDto;
import com.meiyou.result.PageResult;
import com.meiyou.result.Result;
import com.meiyou.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 举报文章
     *
     * @param reportArticleDto
     * @return
     */
    @PostMapping
    public Result reportArticle(@RequestBody ReportArticleDto reportArticleDto) {

        reportService.reportArticle(reportArticleDto);

        return Result.success("举报成功！");
    }

    /**
     * 处理举报
     *
     * @return
     */
    @PostMapping("/handle")
    public Result handleReport(@RequestBody HandleReportDto handleReportDto) {

        reportService.handleReport(handleReportDto);

        return Result.success("操作成功！");
    }

    /**
     * 分页获取举报列表
     *
     * @return
     */
    @GetMapping
    public Result<PageResult> getReportPage(ReportPageDto reportPageDto) {

        PageResult pageResult = reportService.getReportPage(reportPageDto);

        return Result.success(pageResult);
    }

}

